home *** CD-ROM | disk | FTP | other *** search
- /* alert.c MW C V.2.0. pp224,225 3June 1987 CJPurcell exercise..... */
- #include <ctype.h>
- #include <stdio.h>
- #include <aesbind.h>
- #define CANTOPEN 0
- #define NOTASCII 1
- #define FOULUP 2
- #define GEMRETURN 3
- #define PATHSEP '\\'
- extern char *rindex();
- char DIRPATH[80] = "B:\\*.*";
- static char *STRING[] = {
- "[2][ Cannot Open File ][ Return|Try Again ]",
- "[3][ File is not ASCII ][ Ok ]",
- "[3][ Foul-up in fsel_input ][ Ok ]",
- "[3][ Return to GEM ][ Ok ]" };
- /* MAIN */
- main()
- {
- FILE *fp;
- register char *cp;
- char name[80],
- fullname[80];
- int button, ch, ldp, lcp, i;
- appl_init();
- for(;;)
- {
- if(fsel_input(DIRPATH,name,&button)==0) alert(FOULUP);
- if ( button == 0 ) alert(GEMRETURN);
- cp = rindex(DIRPATH, PATHSEP);
- lcp = strlen(cp) - 1 ;
- ldp = strlen(DIRPATH);
- for( i=0 ; i < (ldp + lcp) ; i ++ )
- {
- fullname[i] = '\0' ; /* pre-clear fullname */
- }
- strncpy(fullname, DIRPATH, (ldp - lcp));
- strncat(fullname, name, 12);
- printf("******** Quick scan of %s !******** \n ", fullname);
- if ((fp = fopen(fullname, "r")) == 0) alert(CANTOPEN);
- while ((ch = fgetc(fp)) != EOF)
- {
- if (isascii(ch)) putchar(ch);
- else alert(NOTASCII);
- }
- printf("*****Close after scan of %s !****** \n ", fullname);
- fclose(fp);
- }
- evnt_keybd();
- appl_exit();
- exit(0);
- }
- /* FUNCTION alert */
- alert(flag) int flag;
- {
- int button = 1;
- if(flag > GEMRETURN) flag = GEMRETURN;
- if(form_alert(button, STRING[flag]) == 2)
- return;
- appl_exit();
- exit(1);
- }
-
-
-
-
-
-
- /*************************************************************************/
- /* Consider: */
- /* 16 buttons label 16 file names */
- /* " preset */
- /* " file selector space or */
- /* etc. stacked */
- /* " GEM MORE PRINT EXECUTE (saved) */
- /* return " lpr func */
- /*************************************************************************/
-